Trigger element's onclick method with JQuery [ASP.NET]
Posted
by blu
on Stack Overflow
See other posts from Stack Overflow
or by blu
Published on 2010-04-16T14:14:15Z
Indexed on
2010/04/16
14:23 UTC
Read the original article
Hit count: 471
I have an ASP.NET server control that inherits from CheckBoxList that renders the controls with a UL and LIs. The control is set to AutoPostBack.
Markup:
<div id="foo">
<ul>
<li>
<input type="checkbox"
onclick="javascript:setTimeout('__doPostBack(..."
... />
<label ... />
</li>
</ul>
</div>
I would like to trigger the JavaScript that is rendered on the CheckBox when the parent LI is clicked. Here is what I have so far:
$("#foo li").click(function() {
$(this).find("input:eq(0)").trigger("click");
});
This fires a postback in FF 3.x but the event handler in the codebehind is not fired. In IE 7 a script error comes up and the browser just kind of hangs there for a bit then reloads the page.
How should I be doing this?
© Stack Overflow or respective owner